home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / var / lib / dpkg / info / ghostscript-cups.postinst < prev    next >
Text File  |  2009-10-12  |  3KB  |  80 lines

  1. #! /bin/sh
  2. # postinst script for ghostscript-cups
  3. #
  4. # see: dh_installdeb(1)
  5.  
  6. set -e
  7.  
  8. # summary of how this script can be called:
  9. #        * <postinst> `configure' <most-recently-configured-version>
  10. #        * <old-postinst> `abort-upgrade' <new version>
  11. #        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
  12. #          <new-version>
  13. #        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
  14. #          <failed-install-package> <version> `removing'
  15. #          <conflicting-package> <version>
  16. # for details, see http://www.debian.org/doc/debian-policy/ or
  17. # the debian-policy package
  18. #
  19.  
  20. case "$1" in
  21.     configure)
  22.         # Do the following only if CUPS is running and the needed CUPS tools
  23.         # are available
  24.     if which lpstat > /dev/null 2>&1 && \
  25.         which lpinfo > /dev/null 2>&1 && \
  26.         which lpadmin > /dev/null 2>&1 && \
  27.         LC_ALL=C lpstat -h /var/run/cups/cups.sock -r | grep -v not > /dev/null 2>&1; then
  28.         # Update the PPD files of all already installed print queues
  29.         driverregexp='lsb/usr/ghostscript/'
  30.         gennicknameregexp=''
  31.         [ ! -z "$gennicknameregexp" ] && \
  32.         gennicknameregexp="; $gennicknameregexp"
  33.         gennicknameregexp='s/\s*\(recommended\)//'"$gennicknameregexp"
  34.         tempfiles=
  35.         trap 'rm -f $tempfiles; exit 0' 0 HUP INT QUIT ILL ABRT PIPE TERM
  36.         tmpfile1=`mktemp -t updateppds.XXXXXX`
  37.         tempfiles="$tempfiles $tmpfile1"
  38.         lpinfo -h /var/run/cups/cups.sock -m | grep -E $driverregexp > $tmpfile1
  39.         cd /etc/cups/ppd
  40.         for ppd in *.ppd; do
  41.         [ -r "$ppd" ] || continue
  42.         queue=${ppd%.ppd}
  43.         lpstat -h /var/run/cups/cups.sock -p "$queue" >/dev/null 2>&1 || continue
  44.         nickname=`grep '\*NickName:' "$ppd" | cut -d '"' -f 2 | perl -p -e 's/\n$//' | perl -p -e "$gennicknameregexp" | perl -p -e 's/(\W)/\\\\$1/g'`
  45.         lang=`grep '\*LanguageVersion:' "$ppd" | cut -d ' ' -f 2 | perl -e 'print lc(<>)' | perl -p -e 's/[\r\n]//gs'`
  46.         ppdfound="0"
  47.         englishppduri=""
  48.         tmpfile2=`mktemp -t updateppds.XXXXXX`
  49.         tempfiles="$tempfiles $tmpfile2"
  50.         cat $tmpfile1 | perl -p -e "$gennicknameregexp" | grep -E '^\S+\s+.*'"$nickname"'$' | cut -d ' ' -f 1 > $tmpfile2
  51.         while read newppduri; do
  52.             [ "$ppdfound" = "0" ] && lpadmin -h /var/run/cups/cups.sock -p "$queue" -m $newppduri 2>/dev/null || continue
  53.             newlang=`grep '\*LanguageVersion:' "$ppd" | cut -d ' ' -f 2 | perl -e 'print lc(<>)' | perl -p -e 's/[\r\n]//gs'`
  54.             [ "$newlang" = "$lang" ] && ppdfound="1"
  55.             [ "$newlang" = "english" ] && englishppduri="$newppduri"
  56.         done < $tmpfile2
  57.         [ "$ppdfound" = "0" ] && [ ! -z "$englishppduri" ] && lpadmin -h /var/run/cups/cups.sock -p "$queue" -m $englishppduri 2>/dev/null && ppdfound="1"
  58.         [ "$ppdfound" = "1" ] && echo PPD for printer $queue updated >&2
  59.         done
  60.     fi
  61.  
  62.     ;;
  63.  
  64.     abort-upgrade|abort-remove|abort-deconfigure)
  65.  
  66.     ;;
  67.  
  68.     *)
  69.         echo "postinst called with unknown argument \`$1'" >&2
  70.         exit 1
  71.     ;;
  72. esac
  73.  
  74. # dh_installdeb will replace this with shell code automatically
  75. # generated by other debhelper scripts.
  76.  
  77.  
  78.  
  79. exit 0
  80.